#include<bits/stdc++.h>
using namespace std;
int a[200005],b[200005];
int ans=INT_MIN;
int n;
int check()
{
    int sum=0;
    for(int i=2;i<=n;i++)
    {
        int k=i;
        while(k--&&k>=1)
        {
            if(b[k]==b[i])
            {
                if(a[k]==a[i]) sum+=a[k];
                break;
            }
        }
    }
    return sum;
}
void color(int dep)
{
    if(dep>n)
    {
        ans=max(ans,check());
    }
    else
    {
        for(int i=1;i<=2;i++)
        {
            b[dep]=i;
            color(dep+1);
        }
    }
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
	int T;
	cin>>T;
	while(T--)
	{
	    ans=INT_MIN;
        cin>>n;
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        color(1);
        cout<<ans<<endl;
	}
    return 0;
}
